package com.zlm.design.decorator;

import cn.hutool.core.date.StopWatch;

import java.io.File;
import java.io.FileInputStream;
import java.util.*;

/**
 * @author zlm
 * @date 2025/4/18
 */
public class Main {
    public static void main(String[] args){
        //testHistorySet();
        File file = new File("123.pdf");

        StopWatch stopWatch = new StopWatch();
        stopWatch.start("1");
        try
                ( FileInputStream fileInputStream = new FileInputStream(file);
            BufferedFileInputStream bufferedFileInputStream = new BufferedFileInputStream(new FileInputStream(file));
                   ){
            while (true){
                int read = fileInputStream.read();
                int bufferRead = bufferedFileInputStream.read();
                if (read != bufferRead){
                    System.out.println("不一致");
                }
                if (read == -1){
                    break;
                }
            }
            stopWatch.stop();
            System.out.println("执行耗时ms： "+stopWatch.getTotalTimeMillis());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }


    }

    private static void testHistorySet() {
        HistorySet<String> historySet = new HistorySet<>(new HashSet<>());
        HistorySet<String> set = new HistorySet<>(historySet);
        set.add("6");
        set.add("1");
        set.add("2");
        set.add("3");
        set.add("4");
        set.add("5");
        set.add("7");

        set.remove("1");
        set.remove("3");
        set.remove("4");
        System.out.println(set);
        Collection<Object> objects = Collections.synchronizedCollection(new ArrayList<>());
    }
}
